﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ShrinkWrap.Minifier;
using System.IO;
using NUnit.Framework;

namespace ShrinkWrap.Test.Minifier
{
    abstract public class MinifierFixture
    {
        public abstract String dataFolder { get; }
        public abstract String fileExtension { get; }

        public void AssertFileMinificationIsCorrect(String filename, IMinifier minifier)
        {
            String input = File.ReadAllText(DataPathWithExtension(filename));
            String expected = File.ReadAllText(MinifiedDataPath(filename));
            AssertMinificationIsCorrect(expected, input, minifier);
        }

        public void AssertMinificationIsCorrect(String expected, String input, IMinifier minifer)
        {
            String actual = minifer.Minify(input);
            Assert.AreEqual(expected, actual);
        }

        public String DataPathWithExtension(String filename)
        {
            return DataPath(filename) + "." + fileExtension;
        }

        public String DataPath(String filename)
        {
            return Directory.GetCurrentDirectory() + @"\" + dataFolder + filename;
        }

        public String MinifiedDataPath(String filename)
        {
            return dataFolder + filename + ".min." + fileExtension;
        }
    }
}
